package com.etcn.common.pojo;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;

import com.etcn.common.beanvalidator.Group1;
import com.etcn.common.utils.JsonHandler;

public class Sms implements Serializable{

	private static final long serialVersionUID = 1L;

	/**
	 * 手机号码
	 */
	private String mobilePhoneNumber;
	
	/**
	 * 短信模板
	 */
	private String template;
	
	/**
	 * 发送类型(1:验证码类型，2：通知类型，3：营销类型)
	 */
	private Integer sendType;
	
	/**
	 * 参数封装
	 */
	private Map<String,Object> params = new HashMap<String,Object>();

	@NotBlank(message="手机号不能为空",groups={Group1.class})
	public String getMobilePhoneNumber() {
		return mobilePhoneNumber;
	}

	@NotBlank(message="短信模板不能为空",groups={Group1.class})
	public String getTemplate() {
		return template;
	}

	public void setMobilePhoneNumber(String mobilePhoneNumber) {
		this.mobilePhoneNumber = mobilePhoneNumber;
	}

	public void setTemplate(String template) {
		this.template = template;
	}
	
	@NotNull(message="短信类型不能为空",groups={Group1.class})
	public Integer getSendType() {
		return sendType;
	}

	public void setSendType(Integer sendType) {
		this.sendType = sendType;
	}

	public Map<String, Object> getParams() {
		params.put("mobilePhoneNumber", mobilePhoneNumber);
		params.put("template", template);
		return params;
	}

	public void addParams(String key,String value){
		this.params.put(key, value);
	}

	public Sms(){}
	
	@Override
	public String toString() {
		String jsonStr = null;
		try {
			jsonStr = JsonHandler.buildNoNull().toJson(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jsonStr;
	}
	
}
